import request from '@/request';

export const fetchUserList = function <T, U>(params: T): Promise<U> {
    return request({
        method: 'get',
        url: 'user/list',
        params,
    });
};

export const fetchUserDetail = function <U>(id: string): Promise<U> {
    return request({
        method: 'get',
        url: 'user/detail/' + id,
    });
};

export const fetchEditUser = function <T, U>(id: string, data: T): Promise<U> {
    return request({
        method: 'post',
        url: '/user/update/' + id,
        data,
    });
};

export const fetchCreateUser = function <T, U>(data: T): Promise<U> {
    return request({
        method: 'post',
        url: '/user/create',
        data,
    });
};

export const fetchDeleteUser = function <U>(id: string): Promise<U> {
    return request({
        method: 'delete',
        url: '/user/delete/' + id,
    });
};
